import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
import { type PaginationProps } from "@pureadmin/table";
//系统设置模块
//保存系统信息
type ResultSystem = {
  isSuccess: boolean;
  result?: string;
  pageInfo?: string;
  msg?: string;
};
type resultAPI = {
  isSuccess?: boolean;
  success?: boolean;
  msg?: string;
  pageInfo?: object;
  result?: Array<any>;
  onePage?: PaginationProps;
  data?: any;
};
type ResulGetSystem = {
  isSuccess: boolean;
  data?: any;
  result?: any;
  pageInfo?: string;
  msg?: string;
};

//保存系统信息
export const saveSystemInfo = (data?: object) => {
  return http.request<ResultSystem>("post", baseUrlApi("System/saveSysInfo"), {
    data
  });
};

//获取系统信息
export const getSystemInfo = () => {
  return http.request<ResulGetSystem>("get", baseUrlApi("System/getSysInfo"));
};

//还原系统备份
export const RestoreSystemBackup = (params?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/sysDataReduction"),
    { params }
  );
};

//查询系统备份
export const getSystemBackUp = (data?: object) => {
  return http.request<ResulGetSystem>("post", baseUrlApi("System/selectData"), {
    data
  });
};

//新建系统备份
export const NewSystemBackup = (params?: object) => {
  return http.request<ResulGetSystem>("get", baseUrlApi("System/sysDataBack"), {
    params
  });
};

//删除备份
export const deleteSystemBackup = (data?: object) => {
  return http.request<ResulGetSystem>("post", baseUrlApi("System/deleteData"), {
    data
  });
};

//获取数据日志
export const getSystemLog = (data?: object) => {
  return http.request<ResulGetSystem>("post", baseUrlApi("System/getSysLog"), {
    data
  });
};

//获取发送消息
export const getMessage = (data?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/getAllMessage"),
    { data }
  );
};

//添加消息
export const addMessage = (data?: object) => {
  return http.request<ResulGetSystem>("post", baseUrlApi("System/addMessage"), {
    data
  });
};

//删除消息
export const deleteMessage = (data?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/deleteMessage"),
    {
      data
    }
  );
};

//获取应用列表
export const getAllAplications = (params?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("Analysis/getUserAppList"),
    { params }
  );
};

//获取微信模板所有的列表数据
export const getSysWeiXinMsgModeAllList = (data?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/getSysWeiXinMsgModeList"),
    {
      data
    }
  );
};

//通过ID获取单个微信消息模板
export const getSysWeiXinMsgModeByIds = (data?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/getSysWeiXinMsgModeById"),
    {
      data
    }
  );
};

//保存或是修改微信消息模板
export const saveSysWeiXinMsgModes = (data?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/saveSysWeiXinMsgMode"),
    { data }
  );
};

//删除微信消息模板
export const delSysWeiXinMsgModes = (params?: object) => {
  return http.request<ResulGetSystem>(
    "post",
    baseUrlApi("System/delSysWeiXinMsgMode"),
    { params }
  );
};

//================下面是对AI配置进行设置  作者：李成 2024年7月5日===========================
//获取微信模板所有的列表数据
export const getAICodList = (data?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("System/getSysAICodeList"),
    {
      data
    }
  );
};

//通过ID获取单个微信消息模板
export const getAICodByID = (data?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("System/getSysAICodeByID"),
    {
      data
    }
  );
};

//保存或是修改微信消息模板
export const saveAICode = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("System/saveSysAICode"), {
    data
  });
};

//删除微信消息模板
export const delAICode = (params?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("System/delSysAICode"), {
    params
  });
};
